/**
 * Created by Administrator on 2017/4/21.
 */
let pool = require ('./MysqlDBconnection');
let logger = require ('../logger/Logger');
module.exports.sqlStatement = function ( _param, callBack )
{
    pool.getPoolConnection ('localhost', function ( err, connection )
    {
        if (err)
        {
            logger.error ('[Mysql logs]: get connection from pool in DB: ', err);
            return;
        }
        let [ sql, arr ] = _param;
        connection.query (sql, arr, function ( queryErr, rows )
        {
            if (queryErr)
            {
                logger.warn ('[Mysql logs]: something borken in querySQL ->', queryErr);
                callBack ({
                    isSuccess: false
                });
            }
            else
            {
                callBack ({
                    isSuccess: true,
                    result   : rows
                });
            }
            connection.release ();
        });
    });
};

